package com.ruoyi.hatha.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hatha.domain.PMytaocan;
import com.ruoyi.hatha.service.IPMytaocanService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 我的套餐Controller
 * 
 * @author Dong
 * @date 2024-03-12
 */
@RestController
@RequestMapping("/hatha/mytaocan")
public class PMytaocanController extends BaseController
{
    @Autowired
    private IPMytaocanService pMytaocanService;

    /**
     * 查询我的套餐列表
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:list')")
    @GetMapping("/list")
    public TableDataInfo list(PMytaocan pMytaocan)
    {
        startPage();
        List<PMytaocan> list = pMytaocanService.selectPMytaocanList(pMytaocan);
        return getDataTable(list);
    }

    /**
     * 导出我的套餐列表
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:export')")
    @Log(title = "我的套餐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PMytaocan pMytaocan)
    {
        List<PMytaocan> list = pMytaocanService.selectPMytaocanList(pMytaocan);
        ExcelUtil<PMytaocan> util = new ExcelUtil<PMytaocan>(PMytaocan.class);
        util.exportExcel(response, list, "我的套餐数据");
    }

    /**
     * 获取我的套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pMytaocanService.selectPMytaocanById(id));
    }

    /**
     * 新增我的套餐
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:add')")
    @Log(title = "我的套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PMytaocan pMytaocan)
    {
        return toAjax(pMytaocanService.insertPMytaocan(pMytaocan));
    }

    /**
     * 修改我的套餐
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:edit')")
    @Log(title = "我的套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PMytaocan pMytaocan)
    {
        return toAjax(pMytaocanService.updatePMytaocan(pMytaocan));
    }

    /**
     * 删除我的套餐
     */
    @PreAuthorize("@ss.hasPermi('hatha:mytaocan:remove')")
    @Log(title = "我的套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pMytaocanService.deletePMytaocanByIds(ids));
    }
}
